﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewRequest.aspx.cs" Inherits="ProductPayReim.NewRequest" %>

<%@ Register Src="../../Processes/ProcessControl/UserInfo_TY.ascx" TagName="UserInfo"
    TagPrefix="ui" %>
<%@ Register Src="../../Processes/ProcessControl/ApprovalHistory_TY.ascx" TagName="ApprovalHistory"
    TagPrefix="ah" %>
<%@ Register Src="../../Processes/ProcessControl/Attachments_TY.ascx" TagName="Attachments"
    TagPrefix="attach" %>
<%@ Register Src="../../Processes/ProcessControl/ButtonList_TY.ascx" TagName="ButtonList"
    TagPrefix="btn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>生产采购类资金支付及发票报销</title>
    <script src="../../js/jquery.js" type="text/javascript"></script>
    <script src="../../js/common.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" language="javascript">

        //删除当前行
        function deletetS(rows) {

            $(rows).parent().parent().find("[id*=fld_HTBH]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_GYSMC]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_NR]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_HTJE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_HTSL]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_GHSL]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_YKPJE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_YFJE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_SXJE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_YJFKSJ]").attr("class", ".");

        }

        $(document).ready(function () {
            check();
            getSumJE();

            //我的申请替换表单类型  
            if (request("Type") == "myrequest") {
                $("#rdoType").css("display", "none");
                $("#divType").css("display", "block");
            }

            jQuery("");
            $("#fld_XGRYMC").keydown(function (event) {
                return false;
            });

        });

        //发票金额计算
        function changeRMB_FP() {
            var JE = $("#fld_FPJE").val();
            $("#var_SQJE").val(JE);

            var STRRMB = ChangeRMB(JE);
            $("#fld_FPJEDX").val(STRRMB);
            $("#txt_FPJEDX").text(STRRMB);
        }

        function getSumJE() {
            var Sum_JE = 0;
            $("#tbDetail tr:gt(0)").each(function (i, Etr) {
                Sum_JE += $(Etr).find("td:eq(9)").children().val() - 0;
            });
            $("#fld_FKJE").val(Sum_JE);
            $("#txt_FKJE").text(Sum_JE);
            $("#var_SQJE").val(Sum_JE);
            var STRRMB = ChangeRMB($("#fld_FKJE").val());
            $("#fld_FKJEDX").val(STRRMB);
            $("#txt_FKJEDX").text(STRRMB);

        }

        function check() {
            jQuery('#form1').validationEngine('hide');
            $("#txt_FKJEDX").text($("#fld_FKJEDX").val());
            $("#txt_FKJE").text($("#fld_FKJE").val());

            $("#txt_FPJEDX").text($("#fld_FPJEDX").val());
            if ($("#fld_ZJZF").attr("checked")) {
                $("#var_SQJE").val($("#fld_FKJE").val());
                $("#var_XZZXSP").val($("#fld_ZXSP option:selected").val());

                document.getElementById("DivMoney").style.display = "";
                document.getElementById("DivContract").style.display = "none";
                $("#txtTemp").val("资金支付类");
            } else {
                $("#txtTemp").val("发票报销类");
                $("#var_SQJE").val($("#fld_FPJE").val());
                $("#var_XZZXSP").val($("#fld_FPZXSP option:selected").val());
                document.getElementById("DivMoney").style.display = "none";
                document.getElementById("DivContract").style.display = "";
            }
        }
        //定义多行弹出页面方法
        function Tests(ert) {
            val = window.showModalDialog("../../Modules/Portal/FromEbs.aspx", null, "dialogWidth=850px;dialogHeight=500px");
            if (val) {
                var obj = eval('(' + val + ')');
                if (obj) {
                    $(ert).parent().parent().find("[id*=fld_HTBH]").val(obj.htbh);
                    $(ert).parent().parent().find("[id*=fld_GYSMC]").val(obj.gysmc);
                    $(ert).parent().parent().find("[id*=fld_NR]").val(obj.note);
                    $(ert).parent().parent().find("[id*=fld_HTJE]").val(obj.htje);
                    $(ert).parent().parent().find("[id*=fld_HTSL]").val(obj.htsl);
                    $(ert).parent().parent().find("[id*=fld_GHSL]").val(obj.rksl);
                    $(ert).parent().parent().find("[id*=fld_YKPJE]").val(obj.ykpje);
                    $(ert).parent().parent().find("[id*=fld_YFJE]").val(obj.yfje);
                }
            }
        }

        //校验本次付款金额+已付款金额是否大于合同金额
        function Find(ert) {
            var htje = parseFloat($(ert).parent().parent().find("[id*=fld_HTJE]").val());
            var yfje = parseFloat($(ert).parent().parent().find("[id*=fld_YFJE]").val());
            var bcfkje = parseFloat($(ert).parent().parent().find("[id*=fld_SXJE]").val());
            if (htje < yfje + bcfkje) {
                alert("已付金额加本次需要金额必须小于等于合同金额");
                $(ert).parent().parent().find("[id*=fld_SXJE]").val("");
            }
        }


    </script>
    <script type="text/javascript" language="javascript">
        window.onload = function () {
            document.getElementById("fld_YHKH").onkeyup = function () {
                this.value = this.value.replace(/\s/g, '').replace(/(\d{4})(?=\d)/g, "$1 "); ;
            };
        }; </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="display: none">
        <asp:TextBox ID="var_XZZXSP" runat="server"></asp:TextBox>
        <asp:TextBox ID="var_SQJE" runat="server"></asp:TextBox>
    </div>
    <div class="container">
        <div class="row">
            <ui:userinfo id="UserInfo1" processtitle="生产采购类资金支付及发票报销" processprefix="CIE" tablename="PROC_PRODUCTPAYREIM"
                tablenamedetail="PROC_PRODUCTPAYREIM_DETAIL" runat="server">
            </ui:userinfo>
        </div>
        <div class="row">
            <table class="table table-condensed table-bordered">
                <thead class="table table-condensed table-bordered">
                    <tr>
                        <td class="td-label">
                            表单类别<span class="red">*</span>
                        </td>
                        <td class="td-content" colspan="3">
                            <div id="rdoType">
                                <span onclick="check()">
                                    <asp:RadioButton ID="fld_ZJZF" runat="server" Checked="true" GroupName="rdos" Text="资金支付类" /></span>
                                <span onclick="check()">
                                    <asp:RadioButton ID="fld_FPBX" runat="server" GroupName="rdos" Text="发票报销类" /></span>
                            </div>
                            <div id="divType" style="display: none;">
                                <asp:TextBox ID="txtTemp" runat="server"></asp:TextBox>
                            </div>
                        </td>
                    </tr>
                </thead>
                <tbody id="DivMoney" class="table table-condensed table-bordered">
                    <tr>
                        <td class="banner" colspan="4">
                            资金支付类
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            是否在预算内：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:DropDownList ID="fld_SFYS" runat="server" CssClass="validate[required]">
                                <asp:ListItem Value="">--请选择--</asp:ListItem>
                                <asp:ListItem Value="是">是</asp:ListItem>
                                <asp:ListItem Value="否">否</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td class="td-label">
                            选择中心审批：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:DropDownList ID="fld_ZXSP" runat="server" CssClass="validate[required]">
                                <asp:ListItem Value="">--请选择--</asp:ListItem>
                                <asp:ListItem Value="工程中心">工程中心</asp:ListItem>
                                <asp:ListItem Value="服务中心">服务中心</asp:ListItem>
                                <asp:ListItem Value="咨询中心">咨询中心</asp:ListItem>
                                <asp:ListItem Value="国际服务部">国际服务部</asp:ListItem>
                                <asp:ListItem Value="软件中心">软件中心</asp:ListItem>
                                <asp:ListItem Value="技术中心">技术中心</asp:ListItem>
                                <asp:ListItem Value="运营管理中心">运营管理中心</asp:ListItem>
                                <asp:ListItem Value="市场部">市场部</asp:ListItem>
                                <asp:ListItem Value="财务部">财务部</asp:ListItem>
                                <asp:ListItem Value="质量安全部">质量安全部</asp:ListItem>
                                <asp:ListItem Value="人力资源部">人力资源部</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            付款金额：
                        </td>
                        <td class="td-content">
                            <asp:Label ID="txt_FKJE" runat="server" Text=""></asp:Label>
                            <asp:TextBox ID="fld_FKJE" runat="server" Style="display: none"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            付款金额大写：
                        </td>
                        <td class="td-content">
                            <asp:Label ID="txt_FKJEDX" runat="server"></asp:Label>
                            <asp:TextBox ID="fld_FKJEDX" runat="server" Style="display: none"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            开户行：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_KHH" runat="server" class="validate[required]"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            银行卡号：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_YHKH" runat="server" class="validate[required]"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            付款信息：
                        </td>
                        <td class="td-content" colspan="3">
                            <asp:TextBox ID="fld_FKXX" runat="server"></asp:TextBox>
                        </td>
                        <%--                        <td class="td-label">
                            销售合同号：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_FKHTH" runat="server" CssClass="validate[required]"></asp:TextBox>
                        </td>--%>
                    </tr>
                    <tr>
                        <td class="td-label">
                            选择相关人员：
                        </td>
                        <td class="td-content" colspan="3">
                            <asp:TextBox ID="fld_XGRYMC" runat="server" Width="80%"></asp:TextBox>
                            <asp:TextBox ID="fld_XGRY" runat="server" Width="80%" Style="display: none"></asp:TextBox>
                            <input type="button" value="选择" class="btn" onclick="selectUser(2,'fld_XGRYMC','fld_XGRY')" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="11">
                            <table id="tbDetail" class="table table-condensed table-bordered tablerequired">
                                <tr>
                                    <th>
                                        关联
                                    </th>
                                    <th>
                                        合同编号
                                    </th>
                                    <th>
                                        收款方名称
                                    </th>
                                    <th>
                                        内容
                                    </th>
                                    <th>
                                        合同金额
                                    </th>
                                    <th>
                                        合同数量
                                    </th>
                                    <th>
                                        入库数量
                                    </th>
                                    <th>
                                        已开票金额
                                    </th>
                                    <th>
                                        已付金额
                                    </th>
                                    <th>
                                        本次所需金额
                                    </th>
                                    <th>
                                        预计付款时间
                                    </th>
                                    <th>
                                        <asp:Button ID="btnAdd" runat="server" Text="增加" CssClass="btn" OnClick="btnAdd_Click" />
                                    </th>
                                </tr>
                                <asp:Repeater ID="fld_detail_PROC_PRODUCTPAYREIM_DETAIL" runat="server" OnItemCommand="fld_detail_PROC_PRODUCTPAYREIM_DETAIL_ItemCommand">
                                    <ItemTemplate>
                                        <tr>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_FORMID" Text='<%#Eval("FORMID") %>' runat="server" Style="display: none"></asp:TextBox>
                                                <asp:Label ID="select" Text="点击查询" onclick="Tests(this)" runat="server" Width="80%"
                                                    Style="text-decoration: underline; color: Blue; cursor: pointer;"></asp:Label>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_HTBH" Text='<%#Eval("HTBH") %>' runat="server" Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_GYSMC" Text='<%#Eval("GYSMC") %>' runat="server" Width="80%"
                                                    CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_NR" Text='<%#Eval("NR") %>' runat="server" Width="80%" CssClass="validate[required]"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_HTJE" Text='<%#Eval("HTJE") %>' money="money" runat="server"
                                                    Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_HTSL" Text='<%#Eval("HTSL") %>' money="money" runat="server"
                                                    Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_GHSL" Text='<%#Eval("GHSL") %>' money="money" runat="server"
                                                    Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_YKPJE" Text='<%#Eval("YKPJE") %>' money="money" runat="server"
                                                    Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_YFJE" Text='<%#Eval("YFJE") %>' money="money" runat="server"
                                                    Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_SXJE" Text='<%#Eval("SXJE") %>' runat="server" money="money"
                                                    Width="80%" onkeyup="getSumJE();" onblur="Find(this)" CssClass="validate[required,custom[number]]"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_YJFKSJ" Text='<%#Eval("YJFKSJ") %>' runat="server" Width="80%"
                                                    OnClick="WdatePicker()" CssClass="validate[required]  Wdate"></asp:TextBox>
                                            </td>
                                            <td class="td-label">
                                                <asp:Button ID="btnDelete" runat="server" Text="删除" CssClass="btn" CommandName="del"
                                                    ClientIDMode="Static" OnClientClick="deletetS(this);return confirm('确认删除？')" />
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </table>
                        </td>
                    </tr>
                </tbody>
                <tbody id="DivContract" style="display: none;" class="table table-condensed table-bordered">
                    <tr>
                        <td class="banner" colspan="4">
                            发票报销类
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            发票所属公司：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_FPSSGS" runat="server" CssClass="validate[required]"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            选择中心审批：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:DropDownList ID="fld_FPZXSP" runat="server" CssClass="validate[required]">
                                <asp:ListItem Value="">--请选择--</asp:ListItem>
                                <asp:ListItem Value="工程中心">工程中心</asp:ListItem>
                                <asp:ListItem Value="服务中心">服务中心</asp:ListItem>
                                <asp:ListItem Value="咨询中心">咨询中心</asp:ListItem>
                                <asp:ListItem Value="国际服务部">国际服务部</asp:ListItem>
                                <asp:ListItem Value="软件中心">软件中心</asp:ListItem>
                                <asp:ListItem Value="技术中心">技术中心</asp:ListItem>
                                <asp:ListItem Value="运营管理中心">运营管理中心</asp:ListItem>
                                <asp:ListItem Value="市场部">市场部</asp:ListItem>
                                <asp:ListItem Value="财务部">财务部</asp:ListItem>
                                <asp:ListItem Value="质量安全部">质量安全部</asp:ListItem>
                                <asp:ListItem Value="人力资源部">人力资源部</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            发票金额：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_FPJE" runat="server" onblur="changeRMB_FP();" money="money"
                                CssClass="validate[required,custom[number]]"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            发票金额大写：
                        </td>
                        <td class="td-content">
                            <asp:Label ID="txt_FPJEDX" runat="server"></asp:Label>
                            <asp:TextBox ID="fld_FPJEDX" runat="server" Style="display: none"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            发票信息：
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_FPXX" runat="server"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            发票号：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_FPH" runat="server" CssClass="validate[required]"></asp:TextBox>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="row">
            <attach:attachments id="Attachments1" runat="server"></attach:attachments>
        </div>
        <div class="row">
            <ah:approvalhistory id="ApprovalHistory1" showaction="false" runat="server"></ah:approvalhistory>
        </div>
        <div class="row">
        </div>
    </div>
    <btn:buttonlist id="ButtonList1" runat="server"></btn:buttonlist>
    <div style="display: none;">
    </div>
    </form>
</body>
</html>
